package it.softphone.cmc;

import it.softphone.cmc.shared.entity.AssetImpl;
import it.softphone.cmc.shared.entity.ScriptletAsset;

public class CMCScriptletManager {

	static final String url[] = {
		"http://conv-mobile-mgr.appspot.com",
		 "http://1-alfa21.conv-mobile-mgr.appspot.com"
		
	};

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {

		CMCServiceManager sm = new CMCServiceManager(url[1], "acasolla", "password");
		
		java.util.List<String> keyList = sm.scriptletService.findScriptletKeys(new AssetImpl());
		
		java.io.File destFolder = new java.io.File("src/main/scriptlets");
		
		for( String key : keyList ) {
			System.out.println( "key=" + key );
			
			ScriptletAsset s = sm.scriptletService.findScriptletByKey(key);
			
			java.io.File file = new java.io.File( destFolder, key.concat(".js"));
			
			java.io.FileWriter fw = new java.io.FileWriter(file);
			fw.write(s.getContent());
			fw.close();
			
			
			
		}

	}

}
